<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
        <title>#{bundle.savdepo}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
            <h:form prependId="false">
               <script type="text/javascript">  
                   var doInitForm=false;
                   var tofocus;
                   
                   function changeFocus(nextfcs) {tofocus=nextfcs;}
                   function setDoInitForm(st) {doInitForm=st;}
                   
                   function focusState(xhr, status, args) {  
                       if(args.validationFailed || !args.success) {}
                       else document.getElementById(tofocus).focus();
                       return false;
                   }
                   
                   function handleCompleteSavdpGL(xhr, status, args) {  
                        if(args.validationFailed || !args.success) {
                            
                        }else 
                            setTimeout(function() {
                                if (doInitForm==true) btnNewSavdepogl.jq.click();  
                            }, 3000);
                    }
                    
                    function customRK(e, id, nextfcs) {
                        var code = (e.keyCode ? e.keyCode : e.which);
                        //var element = document.getElementById(id);
        
                        if(code==13) {
                            
                            if (id=="savdepoglSavingNo") {
                                rcsavdepoGLGetSaving();
                                tofocus=nextfcs;
                            }
                            
                            e.preventDefault ? e.preventDefault() : e.returnValue = false;
                            e.stopPropagation();
                       }
                    }
                          
                </script>  
                <p:outputPanel autoUpdate="true">
                <p:toolbar >
                    <p:toolbarGroup align="left">
                        <p:commandButton value="#{bundle.btnNew}" icon="ui-icon-document" update="displaySavdepoGL" 
                                         widgetVar="btnNewSavdepogl"  oncomplete="setDoInitForm(false);"
                                         rendered="#{menuBean.cekButtonAccess(106,'INS;')}"
                                         action="#{savdepoglBean.newData()}" process="@this" >
                            <pe:resetEditableValues for="displaySavdepoGL"/>  
                        </p:commandButton> 
                        
                        <p:commandButton id="submitSavdepoGL" widgetVar="submitSavdepoGL2" value="#{bundle.btnSave}" icon="ui-icon-disk" 
                                         action="#{savdepoglBean.trySave()}" update="displaySavdepoGL"
                                         rendered="#{menuBean.cekButtonAccess(106,'INS;')}" 
                                         oncomplete="setDoInitForm(true); handleCompleteSavdpGL(xhr, status, args);" 
                                         disabled="#{!savdepoglBean.editMode}">
                        </p:commandButton> 
                        
                        
                    </p:toolbarGroup>
                    <p:toolbarGroup align="right">
                        <p:commandButton id="doNothingSavdepoGL" type="button" value="" style="width: 0px; height: 0px;"/> 
                        <p:defaultCommand target="#{savdepoglBean.defaultButton}" /> 
                    </p:toolbarGroup>
                </p:toolbar>
                </p:outputPanel>
                
                <p:remoteCommand name="rcsavdepoGLGetSaving" actionListener="#{savdepoglBean.getSavingSrc('null')}" 
                                 process="@this savdepoglSavingNo" update="savdepGLSaldoawal, hideSavdepGLSavaccntId, savdepoglCustInfo" 
                                 oncomplete="focusState(xhr, status, args);"/> 
                
                <!-- LOOK UP saving -->
                <p:dialog header="#{bundle.Select} #{bundle.accountNo}" widgetVar="dlgSavdepoGLLookupSav" closable="true" dynamic="true" >
                    <p:ajax listener="#{savdepoglBean.handleCloseLookup}" />
                    <h:panelGrid id="displaySavdepoGLLookup" rendered="#{savdepoglBean.showLookup==true}">
                        <ui:include src="../saving/searchSaving.xhtml" >
                            <ui:param name="lookupSavComponenId" value="savGL" />
                        </ui:include> 

                        <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR" >
                            <f:facet name="footer">
                                <p:commandButton value="#{bundle.btnOK}" icon="ui-icon-disk" immediate="true" 
                                                process="@this" update="savdepGLSaldoawal, hideSavdepGLSavaccntId, savdepoglCustInfo"
                                                action="#{savdepoglBean.getSavingSrc(searchSavingBean.selectedData.accountNo)}" 
                                                oncomplete="dlgSavdepoGLLookupSav.hide(); focusState(xhr, status, args);" />

                                <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgSavdepoGLLookupSav.hide()" immediate="true" icon="ui-icon-document" process="@this" />
                            </f:facet>
                        </h:panelGrid>
                    </h:panelGrid>
                </p:dialog>
                
                <h:panelGrid id="displaySavdepoGL" styleClass="addELIT" cellpadding="0" 
                    style="vertical-align: top" columnClasses="panelGridId,panelGridId">
                    <h:panelGrid columns="2" cellpadding="1" border="0" style="vertical-align: top" columnClasses="panelGridId,panelGridId">
                        <p:panel header="#{bundle.establishLedgend}" >
                            <h:panelGrid columns="3" style="width: 100%" cellpadding="0" cellspacing="10">
                                <h:outputLabel value= "#{bundle.date}" /><h:outputLabel value=":"/>
                                <h:outputText value="#{savdepoglBean.savdepo.transDate}" />

                                <p:outputLabel value= "#{bundle.savingNo}" for="savdepoglSavingNo"/><h:outputLabel value=":"/>
                                <h:panelGrid columns="2" cellpadding="0" cellspacing="0">                                
                                    <p:inputText value="#{savdepoglBean.savdepo.saving.accountNo}" style="width: 122px;"
                                        onkeydown="customRK(event, 'savdepoglSavingNo', '#{utilityBean.findClientId('savdepoGLAmount')}')" label="#{bundle.savingNo}" 
                                        id="savdepoglSavingNo" required="true" disabled="#{!savdepoglBean.authorized}"
                                        requiredMessage="#{bundle.savingNo} #{bundle.requiredInput}">
                                    </p:inputText>
                                    <p:commandButton icon="ui-icon-search" iconPos="center" styleClass="btnSmall"
                                                     update="displaySavdepoGLLookup" onclick="changeFocus('#{utilityBean.findClientId('savdepoGLAmount')}');"
                                        process="@this" immediate="true" oncomplete="dlgSavdepoGLLookupSav.show();" disabled="#{!savdepoglBean.editMode}">
                                        <f:setPropertyActionListener target="#{savdepoglBean.showLookup}" value="#{true}" />
                                    </p:commandButton>
                                </h:panelGrid>
                                                                                                                           
                                <h:outputLabel value= "#{bundle.saldoAwal}" /><h:outputLabel value=":"/>
                                <h:outputLabel value="#{savdepoglBean.saldoAwal}" styleClass="numPos" id="savdepGLSaldoawal" style="padding: 0 152px 0 0;">
                                    <f:convertNumber groupingUsed="true" />
                                </h:outputLabel>
                                                                        
                                <p:outputLabel value= "#{bundle.amount}" for="savdepoGLAmount"/><h:outputLabel value=":"/>
                                <h:panelGrid columns="2" cellpadding="0" cellspacing="0">
                                    <pe:inputNumber decimalSeparator="." thousandSeparator="," maxValue="999999999999999.99" minValue="0" 
                                                    value="#{savdepoglBean.savdepo.amount}" style="width: 150px; text-align: right;"
                                        label="#{bundle.amount}" id="savdepoGLAmount" required="true" disabled="#{!savdepoglBean.authorized}"
                                        requiredMessage="#{bundle.amount} #{bundle.requiredInput}" >
                                        <p:ajax update="savdepGLBalance" listener="#{savdepoglBean.calcSaldoAhir}" process="@this" partialSubmit="false"/>
                                    </pe:inputNumber>
                                </h:panelGrid>
                                                                
                                <h:outputLabel value= "#{bundle.balance}" /><h:outputLabel value=":"/>
                                <h:outputLabel value="#{savdepoglBean.saldoAkhir}" styleClass="numPos" id="savdepGLBalance" style="padding: 0 152px 0 0;">
                                     <f:convertNumber groupingUsed="true" />
                                </h:outputLabel>
                                
                                <h:outputLabel for="savdepotrxglId" value= "#{bundle.glaccnt}" /><h:outputLabel value=":"/>
                                <p:selectOneMenu value="#{savdepoglBean.savdepo.savtrxglId}" id="savdepotrxglId" label="#{bundle.glaccnt}" 
                                                     requiredMessage="#{bundle.glaccnt} #{bundle.requiredInput}" style="width: 300px;"
                                                     required="true" disabled="#{!savdepoglBean.authorized}">
                                    <f:selectItem itemLabel="#{bundle.Select} #{bundle.glaccnt}"/>
                                    <f:selectItems value="#{savdepoglBean.availableGL}" var="gl" itemValue="#{gl.savtrxglId}" itemLabel="#{gl.glaccount.accountName}"/>
                                    <p:ajax listener="#{savdepoglBean.handleProdChange}" process="@this" />  
                                </p:selectOneMenu>

                                <h:inputHidden value="#{savdepoglBean.savdepo.saving.savaccntId}" id="hideSavdepGLSavaccntId"
                                    required="true" requiredMessage="#{bundle.savingNo} #{bundle.requiredInput}" />
                                
                            </h:panelGrid>
                        </p:panel>

                        <p:outputPanel autoUpdate="true">
                            <p:panel header="#{bundle.cusledgen}" id="savdepoglCustInfo">
                            <h:panelGrid columns="3" style="width: 100%" cellpadding="0" cellspacing="10">
                                <h:outputLabel value= "#{bundle.cif}" /><h:outputLabel value=":"/>
                                <h:outputText value="#{savdepoglBean.savdepo.saving.customer.cif}" />

                                <h:outputLabel value= "#{bundle.globalName}" /><h:outputLabel value=":"/>
                                <h:outputText value="#{savdepoglBean.savdepo.saving.customer.customerName}" />

                                <h:outputLabel value= "#{bundle.aliasName}" /><h:outputLabel value=":"/>
                                <h:outputText rendered="true" value="#{savdepoglBean.savdepo.saving.customer.aliasName}" />

                                <h:outputLabel value= "#{bundle.npwp}" /><h:outputLabel value=":"/>
                                <h:outputText value="#{savdepoglBean.savdepo.saving.customer.npwp}" />

                                <h:outputLabel style="padding: 0 15px 0 0;" value= "#{bundle.officePhone}" /><h:outputLabel value=":"/>
                                <h:outputText value="#{savdepoglBean.savdepo.saving.customer.cusper.officePhone}"/>

                                <h:outputLabel value= "#{bundle.phone}" /><h:outputLabel value=":"/>
                                <h:outputText value="#{savdepoglBean.savdepo.saving.customer.phone}"/>

                                <h:outputLabel value= "#{bundle.mobilePhone}" /><h:outputLabel value=":"/>
                                <h:outputText value="#{savdepoglBean.savdepo.saving.customer.mobilePhone}"/>
                                
                                <h:outputLabel value= "#{bundle.specimen}" /><h:outputLabel value=":"/>
                                <p:graphicImage  value="/upload/personal/#{savdepoglBean.savdepo.saving.customer.specimen}" />
                                
                            </h:panelGrid>
                        </p:panel>
                        </p:outputPanel>
                    </h:panelGrid>
                </h:panelGrid>
            </h:form>
        </ui:composition>
    </h:body>
</html>

